package com.jobpass.common.controller;


import com.jobpass.common.model.Admin;
import com.jobpass.common.model.Recruit;
import com.jobpass.common.service.AdminService;
import com.jobpass.common.service.RecruitService;
import com.jobpass.utils.RedisUtil;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/admin")
public class AdminController {
    @Resource
    private AdminService adminServiceImpl;
    @Resource
    private RecruitService recruitServiceImpl;
    @GetMapping("/findall")
    public List<Recruit> findall () {
//        return adminServiceImpl.FindAllAdmin();

        RedisUtil.set("hello","word");
        Admin admin = new Admin();
        admin.setTeacherId(2L);
        admin.setGradeId(3L);
        RedisUtil.set("admin",admin);
        RedisUtil.expire("admin",10);
        Object admin1 = RedisUtil.get("admin");

        System.out.println(admin1);

        Object hello = RedisUtil.get("hello");

        RedisTemplate<String,Object> reids = new RedisTemplate<>();



        System.out.println(hello.toString());

        return recruitServiceImpl.FindAllRecruit();
    }


    @GetMapping("/insert")
    public int inserts(){
        Admin admin = new Admin();
        admin.setTeacherId(2L);
        admin.setGradeId(3L);
        return adminServiceImpl.SavaAdmin(admin);
    }

}
